#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json

def count_sum(input_file):
    all = 0
    original = 0
    retweet = 0
    with open(input_file, 'r+') as f:
        for line in f:
            obj = json.loads(line)
            status = obj['status']
            all += 1
            if 0 == status:
                original += 1
            else:
                retweet += 1
    f.close()
    return [str(all), str(original), str(retweet)]


def main():
    output_file = '/home/ivy/git/Social/Social/resource/count.txt'
    with open(output_file, 'w+') as f:
        for date_num in range(20151001, 20151032):
            input_file ='/home/ivy/git/Social/Social/resource/daybyday/%d.txt' % date_num
            f.write('%d\t%s\n' % (date_num, '\t'.join(count_sum(input_file))))
        
if __name__ == '__main__':
    main()
    